﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:c4f="clr-namespace:Coding4Fun.Toolkit.Controls;assembly=Coding4Fun.Toolkit.Controls"
    xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP8"
    xmlns:tkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit">

    <DataTemplate x:Key="ItemTemplate">
        <TextBlock Margin="12,0,0,12" Foreground="Black" Style="{StaticResource PhoneTextTitle2Style}" Text="{Binding}">
            <tkit:ContextMenuService.ContextMenu>
                <tkit:ContextMenu>
                    <tkit:MenuItem Header="delete" Command="{Binding Path=Instance.DeleteSetCommand, Source={StaticResource CommandViewModel}}"
                                   CommandParameter="{Binding}"/>
                </tkit:ContextMenu>
            </tkit:ContextMenuService.ContextMenu>
            
           <i:Interaction.Triggers>
                <i:EventTrigger EventName="Tap">
                    <cmd:EventToCommand Command="{Binding Path=Instance.SelectSetCommand, Source={StaticResource CommandViewModel}}" CommandParameter="{Binding}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </TextBlock>
    </DataTemplate>

    <DataTemplate x:Key="GroupHeader">
        <Border Background="Transparent" Margin="12,0,0,12">
            <Border BorderBrush="White" BorderThickness="1" Background="#faa71a" 	
                                        Padding="8,0,0,0" Width="62" Height="62" 				 
                                        HorizontalAlignment="Left">
                <TextBlock Text="{Binding Key}" 
                           Foreground="White" 
                           FontSize="48"
                           FontFamily="{StaticResource PhoneFontFamilySemiLight}"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Bottom"/>
            </Border>
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="GroupItemTemplate">
        <Border Background="#faa71a" Width="99" Height="99" Margin="6" IsHitTestVisible="{Binding HasItems}">
            <TextBlock Text="{Binding Title}" 
                       FontFamily="{StaticResource PhoneFontFamilySemiBold}"
                       FontSize="48"
                       Margin="8,0,0,0"
                       Foreground="White"                                        
                       VerticalAlignment="Bottom"/>
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="ServerItemTemplate">
        <c4f:Tile Command="{Binding Path=Instance.SelectServerCommand, Source={StaticResource CommandViewModel}}" CommandParameter="{Binding}" FontSize="24" Margin="12,12,0,0" Height="214" Width="214" Label="{Binding Name}" Tag="{Binding}">
            <tkit:ContextMenuService.ContextMenu>
                <tkit:ContextMenu>
                    <tkit:MenuItem Header="remove" Command="{Binding Path=Instance.RemoveServerCommand, Source={StaticResource CommandViewModel}}"
                                   CommandParameter="{Binding}"/>
                </tkit:ContextMenu>
            </tkit:ContextMenuService.ContextMenu>

            <Grid Background="{StaticResource ApplicationThemeColor}">
                <Image Source="/Graphics/home_server.png" Height="128" Width="128" Opacity=".2" 
                       VerticalAlignment="Bottom" HorizontalAlignment="Right"></Image>
                <Image Source="{Binding ImageURL}" Height="214" Width="214" />
            </Grid>
        </c4f:Tile>
    </DataTemplate>

    <DataTemplate x:Key="PadTemplate">
        <Border Width="106" Height="106" Margin="0,0,8,8">
            <tkit:ContextMenuService.ContextMenu>
                <tkit:ContextMenu>
                    <tkit:MenuItem Header="add to quick launch" Command="{Binding Path=Instance.AddToQuickLaunchCommand, Source={StaticResource CommandViewModel}}"
                                   CommandParameter="{Binding}"/>
                    <tkit:MenuItem Header="delete command" Command="{Binding Path=Instance.DeleteCommandCommand, Source={StaticResource CommandViewModel}}"
                                   CommandParameter="{Binding}"/>
                </tkit:ContextMenu>
            </tkit:ContextMenuService.ContextMenu>

            <Grid Background="{StaticResource ApplicationThemeColor}">
                <TextBlock Foreground="White" Text="{Binding}" 
                           Style="{StaticResource PhoneTextLargeStyle}"></TextBlock>
            </Grid>
        </Border>
    </DataTemplate>

    <ControlTemplate x:Key="PhoneDisabledTextBoxTemplate" TargetType="TextBox">
        <ContentControl x:Name="ContentElement" 
                            BorderThickness="0" 
                            HorizontalContentAlignment="Stretch" 
                            Margin="{StaticResource PhoneTextBoxInnerMargin}" 
                            Padding="{TemplateBinding Padding}" 
                            VerticalContentAlignment="Stretch"/>
    </ControlTemplate>

    <DataTemplate x:Key="FavoriteCommandTemplate">
        <Grid Height="100" Background="{StaticResource ApplicationThemeColor}" Margin="0,0,0,8">
            <tkit:ContextMenuService.ContextMenu>
                <tkit:ContextMenu>
                    <tkit:MenuItem Header="remove from quick launch" Command="{Binding Path=Instance.RemoveFromQuickLaunchCommand, Source={StaticResource CommandViewModel}}"
                                   CommandParameter="{Binding}"/>
                </tkit:ContextMenu>
            </tkit:ContextMenuService.ContextMenu>

            <StackPanel>
                <TextBlock Text="{Binding CommandName}" Style="{StaticResource PhoneTextLargeStyle}"></TextBlock>
                <TextBlock Text="{Binding ParentSet}" Style="{StaticResource PhoneTextSmallStyle}"></TextBlock>
            </StackPanel>

            <Image Source="/Graphics/controller.png" Height="96" Width="96" Stretch="Uniform" Opacity=".2" 
                   HorizontalAlignment="Right" VerticalAlignment="Center"></Image>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="GenericCommandTemplate">
        <Grid Height="100" Background="{StaticResource ApplicationThemeColor}" Margin="0,0,0,8">
            <tkit:ContextMenuService.ContextMenu>
                <tkit:ContextMenu>
                    <tkit:MenuItem Header="add to quick launch" Command="{Binding Path=Instance.AddToQuickLaunchCommand, Source={StaticResource CommandViewModel}}"
                                   CommandParameter="{Binding}"/>
                    <tkit:MenuItem Header="delete command" Command="{Binding Path=Instance.DeleteCommandCommand, Source={StaticResource CommandViewModel}}"
                                   CommandParameter="{Binding}"/>
                </tkit:ContextMenu>
            </tkit:ContextMenuService.ContextMenu>

            <StackPanel>
                <TextBlock Text="{Binding}" Style="{StaticResource PhoneTextLargeStyle}"></TextBlock>
            </StackPanel>

            <Image Source="/Graphics/controller.png" Height="96" Width="96" Stretch="Uniform" Opacity=".2" HorizontalAlignment="Right" VerticalAlignment="Center"></Image>
        </Grid>
    </DataTemplate>

    <ItemsPanelTemplate x:Key="WrapPanelTemplate">
        <tkit:WrapPanel />
    </ItemsPanelTemplate>

    <ItemsPanelTemplate x:Key="StackPanelTemplate">
        <VirtualizingStackPanel />
    </ItemsPanelTemplate>
</ResourceDictionary>